#include <iostream>
#include <string>
#include <list>
using namespace std;

class Task 
{
public:
	Task();
	virtual ~Task();
	virtual void doWork();
};
Task::Task()
{
    cout << "Task()" << endl;
}

Task::~Task()
{
    cout << "~Task()" << endl;
}

void Task::doWork()
{
    cout << "Task::doWork()" << endl;
}

class FileMission : public Task
{
public:
	FileMission();
	virtual ~FileMission();
	virtual void doWork();
};
FileMission::FileMission()
{
    cout << "FileMission()" << endl;
}

FileMission::~FileMission()
{
    cout << "~FileMission()" << endl;
}

void FileMission::doWork()
{
    cout << "FileMission::doWork()" << endl;
}

class DbMission : public Task
{
public:
	DbMission();
	virtual ~DbMission();
	virtual void doWork();
};

DbMission::DbMission()
{
    cout << "DbMission()" << endl;
}

DbMission::~DbMission()
{
    cout << "~DbMission()" << endl;
}

void DbMission::doWork()
{
    cout << "DbMission::doWork()" << endl;
}
class OtherMission : public Task
{
public:
	OtherMission();
	virtual ~OtherMission();
	virtual void doWork();
};

OtherMission::OtherMission()
{
    cout << "OtherMission()" << endl;
}

OtherMission::~OtherMission()
{
    cout << "~OtherMission()" << endl;
}

void OtherMission::doWork()
{
    cout << "OtherMission::doWork()" << endl;
}

int main()
{
    list<Task*> missionList;
    missionList.push_back(new FileMission);
    missionList.push_back(new DbMission);
    missionList.push_back(new OtherMission);

    auto it = missionList.begin();
    for(; it != missionList.end(); ++it) {
        (*it)->doWork();
    }
    
    it = missionList.begin();
    for(; it != missionList.end(); ++it) {
        delete (*it);
        (*it) = nullptr;
    }
    missionList.clear();
    return 0;
}
